package com.mangguo.tingjian.mgtjv3.mapper;

import com.mangguo.tingjian.mgtjv3.dto.CategoryMenuDto;
import com.mangguo.tingjian.mgtjv3.entity.CategoryMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 类目菜单表 Mapper 接口
 * </p>
 *
 * @author auto
 * @since 2019-12-12
 */
@Mapper
public interface CategoryMenuMapper extends BaseMapper<CategoryMenu> {

    @Select("SELECT a.name ,c.name as subname ,a.id as menu_id,b.sub_menu_id from mgtjv3.category_menu a                                             \n" +
            "       LEFT JOIN (SELECT menu_id,sub_menu_id from mgtjv3.category_menu_ref where status = 1 ) b ON  a.id=b.menu_id                \n" +
            "       LEFT JOIN mgtjv3.category_menu c on c.id=b.sub_menu_id                                                                     \n" +
            "        where  a.status=1 and a.i_level=1 ORDER BY a.name; ")
    List<CategoryMenuDto> getAllCategoryMenu();
}
